package com.bing.utils;

import com.bing.services.BlogService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created by kaibb on 16-1-16.
 */
public class AppContext implements ApplicationContextAware {
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        AppContext.applicationContext = applicationContext;
    }

    private static ApplicationContext applicationContext;

    private AppContext() {

    }

    public static BlogService getBlogService() {
        return AppContext.applicationContext.getBean(BlogService.class);
    }
}
